package com.fzu.ess.ess.controller;

import com.fzu.ess.common.Model.JsonModel;
import com.fzu.ess.ess.entity.Feedback;
import com.fzu.ess.ess.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by ercha on 2015/10/25.
 */

@Controller
@RequestMapping(value = "/feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;

    @RequestMapping(method = RequestMethod.GET)
    public String createPage() {
        return "/jsp/common/feedback.jsp";
    }

    @ResponseBody
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public JsonModel create(Feedback feedback) {
        return feedbackService.create(feedback);
    }

    @RequestMapping(value = "/myList", method = RequestMethod.GET)
    public String myListPage(){
        return "/jsp/user/feedback/list.jsp";
    }

    @ResponseBody
    @RequestMapping(value = "/ownData", method = RequestMethod.GET)
    public JsonModel getOwnDataByData(@RequestParam(value = "page") Integer pageNumber, @RequestParam Integer pageSize){
        return feedbackService.getOwnByPage(pageNumber, pageSize);
    }

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public String listPage(){
        return "/jsp/admin/feedback/list.jsp";
    }

    @ResponseBody
    @RequestMapping(value = "/pageData", method = RequestMethod.GET)
    public JsonModel getPageData(@RequestParam(value = "page") Integer pageNumber, @RequestParam Integer pageSize){
        return feedbackService.getPageData(pageNumber, pageSize);
    }
}
